//
//  MainTabViewController.m
//  TJProperty
//
//  Created by Miffy@Remmo on 15-5-26.
//  Copyright (c) 2015年 bocweb. All rights reserved.
//

#import "MainTabViewController.h"
#import "MainNavigationController.h"
#import "FirstBarViewController.h"
#import "SecondBarViewController.h"
#import "ThirdBarViewController.h"
#import "FourBarViewController.h"
//#import "MineViewController.h"

@interface MainTabViewController ()

@end

@implementation MainTabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [[UITabBarItem appearance] setTitleTextAttributes:@{
                                                        NSForegroundColorAttributeName : [UIColor blackColor]
                                                        } forState:UIControlStateNormal];
    
    
    [[UITabBarItem appearance] setTitleTextAttributes:@{
                                                        NSForegroundColorAttributeName : [UIColor orangeColor]
                                                        } forState:UIControlStateSelected];
    
  
    
    
    FirstBarViewController *home = [[FirstBarViewController alloc]init];
    [self addChildViewController:home withImageName:@"tabbar_first" title:@"首页"];
    
    SecondBarViewController *life= [[SecondBarViewController alloc]init];
    [self addChildViewController:life withImageName:@"tabbar_tow" title:@"我要理财"];
    
    ThirdBarViewController *brand = [[ThirdBarViewController alloc]init];
    [self addChildViewController:brand withImageName:@"tabbar_third" title:@"活动"];
    
//    FacilityViewController *facility = [[FacilityViewController alloc]init];
//    [self addChildViewController:facility withImageName:@"tabbar_business" title:@"商业配套"];
    FourBarViewController * business=[[FourBarViewController alloc]init];
    [self addChildViewController:business withImageName:@"tabbar_four" title:@"我的账户"];
    
    //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//    MineViewController *mine = [[MineViewController alloc]init];
//    [self addChildViewController:mine withImageName:@"tabbar_mine" title:@"个人空间"];
    //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    
    
    //TabBar背景色
    //    self.tabBar.backgroundImage = [UIImage imageNamed:@"toolbar_background"];
    self.tabBar.tintColor = [UIColor orangeColor];
    
    
    self.tabBar.selectionIndicatorImage = [[UIImage alloc]init];
    
    [self setSelectedIndex:0];
    
}

- (void)addChildViewController:(UIViewController *)childController withImageName:(NSString *)icon title:(NSString *)title
{
    UITabBarItem *item = childController.tabBarItem;
    
    childController.title = title;
    
    NSString *selectIcon = [icon stringByAppendingString:@"_selected"];
    UIImage *iconImage = [UIImage imageNamed:icon];
    UIImage *selectIconImage = [UIImage imageNamed:selectIcon];
    if ([selectIconImage respondsToSelector:@selector(imageWithRenderingMode:)]) {
        selectIconImage = [selectIconImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    }
    
    item.image = iconImage;
    item.selectedImage = selectIconImage;
    
    MainNavigationController *nav = [[MainNavigationController alloc]initWithRootViewController:childController];
    
    [self addChildViewController:nav];
}

@end
